package com.dmxh.fallBack;

import com.dmxh.api.SellerAPI;
import com.dmxh.pojo.TbSeller;
import com.dmxh.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

@Slf4j
public class SellerFallBack implements FallbackFactory<SellerAPI> {

    @Override
    public SellerAPI create(Throwable cause) {
        return new SellerAPI() {
            @Override
            public TbSeller queryByName(String name) {
                //熔断后逻辑
                log.error("查询商家异常", cause);
                return new TbSeller();
            }
            @Override
            public Result queryByIdVoid(Integer id) {
                //如果一个api中有两个接口就重写两个 内部类
                return Result.ok().setData("熔断降级了.....");//
            }
        };
    }
}
